package com.chis.jmdatatimer.comm;

import com.chis.jm.pojo.TdBirthinfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import redis.clients.jedis.ShardedJedis;

/**
 * @Description 根据儿童编码查询儿童新生儿出生状况表
 * @Company zwx
 * @author zww1
 * @version 2018/7/20
 */
public class RedisFindBirthinfoTx implements TransactionJedis {
	/**日志*/
	private static Logger log = LogManager.getLogger(RedisFindBirthinfoTx.class);
	/** 儿童编码 */
	private String childCode;
	/** 新生儿出生状况表 */
	private TdBirthinfo list;

	public RedisFindBirthinfoTx(String childCode) {
		this.childCode = childCode;
	}

	@Override
	public void run(ShardedJedis jedis) throws Exception {

		try {
			jedis.select(12);
			byte[] bytes = jedis.get(childCode.getBytes());
			if (null != bytes && bytes.length > 0) {
				list = (TdBirthinfo) JedisSerializeUtil.unserialize(bytes);
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw new Exception(e.getMessage());
		}

	}

	public TdBirthinfo getList() {
		return list;
	}
}
